package com.bort.system.info;

import com.bort.system.model.Cart;
import com.bort.system.model.Cost;
import com.bort.system.model.TOrder;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

@Data
public class OrderInfo extends TOrder {

    List<Cart> cartList;

    GameInfo gameInfo;

    List<Cost> costList;

    private String description;

    public String getDescription() {
        String desc = "";
        if(gameInfo != null){
            desc += "安子费:"+gameInfo.getAmount()+"元";
        }
        if(cartList != null && cartList.size() > 0){
            if(desc.length() > 0){ desc += ";"; }
            desc +="商品:";
            int i = 0;
            for (Cart cart : cartList) {
                if(i>0){
                    desc += ",";
                }
                desc += cart.getGoodsName() + ":"+cart.getNum() +"个";
                i++;
            }
        }

        if(costList != null && costList.size() > 0){
            for (Cost cost : costList) {
                if(StringUtils.isNotEmpty(desc)){
                    desc += ";";
                }
                desc += cost.getDescription();
            }
        }

        return desc;
    }
}
